//
//  YSDeliverTipsView.m
//  Yueshi
//
//  Created by yueshi－mac1 on 16/1/20.
//  Copyright © 2016年 悦食中国. All rights reserved.
//

#import "YSDeliverTipsView.h"
@interface YSDeliverTipsView()
@end
@implementation YSDeliverTipsView
- (instancetype)initWithExplanation:(NSString *)explanation{
    self = [super init];
    if (self) {
        if (ISBLANK(explanation)) {
            self.bounds = CGRectMake(0, 0, SCREENW, 0);
        }else{
            UIView *splitView = [[UIView alloc]init];
            [splitView setFrame:CGRectMake(YSPublicXInset, 0, SCREENW-YSPublicXInset*2, 0.5)];
            [splitView setBackgroundColor:SPLIT_LINE_COLOR];
            [self addSubview:splitView];
            
            UIImage *image = [UIImage imageNamed:@"express"];
            UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
            imageView.x = YSPublicXInset;
            imageView.y = YSPublicXInset;
            [self addSubview:imageView];
            
            UILabel *label = [[UILabel alloc] init];
            CGSize size = [explanation sizeWithFont:SYS_FONT(16) constrainedToSize:CGSizeMake(SCREENW - YSPublicXInset*2 - image.size.width - 15, MAXFLOAT)];
            label.text = explanation;
            label.font = SYS_FONT(16);
            label.textColor = publicTextColor;
            label.numberOfLines = 0;
            label.frame = CGRectMake(CGRectGetMaxX(imageView.frame) + 15, 10, size.width, size.height);
            [self addSubview:label];
            
            self.bounds = CGRectMake(0, 0, SCREENW, size.height + 20);
        }
    }
    return self;
}
@end
